<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>高考志愿填报辅导系统</title>
    <link rel="stylesheet" type="text/css" href="../../../assets/edu/layui/css/layui.css?v=201805221950"
          th:href="@{/assets/edu/layui/css/layui.css?v=201805221953}">
    <link rel="stylesheet" type="text/css" href="../../../assets/edu/css/css.css" th:href="@{/assets/edu/css/css.css}">
    <script type="text/javascript" src="../../../assets/edu/js/jquery-1.11.3.js"
            th:src="@{/assets/edu/js/jquery-1.11.3.js}"></script>
    <script type="text/javascript" src="../../../assets/edu/layui/layui.js"
            th:src="@{/assets/edu/layui/layui.js}"></script>
    <script type="text/javascript" src="../../../assets/edu/js/common.js"
            th:src="@{/assets/edu/js/common.js?v=201803171720}"></script>
</head>
<body th:inline="none">
<div class="pad10">
    <input type="hidden" th:value="${min}" id="min">
    <input type="hidden" th:value="${max}" id="max">
    <input type="hidden" th:value="${id}" id="hid_id">
    <input type="hidden" th:value="${provinceCode}" id="provinceCode">
    <input type="hidden" th:value="${zymc}" id="zymc">
    <input type="hidden" th:value="${schoolCode}" id="schoolCode">
    <input type="hidden" th:value="${type}" id="type">
    <blockquote class="layui-elem-quote">
        您的成绩：位次：<span id="ranking" th:text="${candidate.ranking}">209524</span>&nbsp;&nbsp;
        分数：<span
            th:text="${candidate.totalScore}">400</span>&nbsp;&nbsp;
        指数：<span th:text="${zs}">1%</span>&nbsp;&nbsp;
        科目：<span
            th:if="${candidate.physics eq 1}">物理&nbsp;</span>
        <span th:if="${candidate.chemistry eq 1}">化学&nbsp;</span><span th:if="${candidate.biology eq 1}">生物&nbsp;</span>
        <span th:if="${candidate.technology eq 1}">技术&nbsp;</span>
        <span th:if="${candidate.history eq 1}">历史&nbsp;</span>
        <span th:if="${candidate.geography eq 1}">地理&nbsp;</span>
        <span th:if="${candidate.politics eq 1}">政治&nbsp;</span>
    </blockquote>
    <form class="layui-form" action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label class="layui-form-label">学校名称</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="schoolName">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">专业名称</label>
                <div class="layui-input-inline">
                    <input type="text" class="layui-input" id="majorName">
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">办学类型</label>
                <div class="layui-input-inline">
                    <select id="bxlx">
                        <option value="">请选择办学类型</option>
                        <option value="1">公办</option>
                        <option value="2">民办</option>
                        <option value="3">独立学院</option>
                        <option value="4">中外合作</option>
                    </select>
                </div>
            </div>
            <div class="layui-inline">
                <label class="layui-form-label">学制</label>
                <div class="layui-input-inline">
                    <select id="xzdm">
                        <option value="">请选择学制</option>
                        <option th:each="xzdm :${xzdms}" th:text="${xzdm.name}" th:value="${xzdm.code}"></option>
                    </select>
                </div>
            </div>
        </div>
        <div class="layui-inline">
            <label class="layui-form-label"></label>
            <a href="javascript:;" class="layui-btn ayui-btn-normal bg-blue " data-type="reload">
                <i class="iconfont">&#xe606;</i> 查询</a>
        </div>
</div>
</form>
<div class="line">
        <span class=line-title>查询结果
            (<span th:if="${type eq '1'}">冲</span><span th:if="${type eq '2'}">稳</span><span
                    th:if="${type eq '3'}">保</span>)红色的专业为新专业
        </span>
</div>
<div class="gkwh-tb">
    <table id="wh-list" style=""></table>
</div>
</div>
<script type="text/html" id="checkboxTpl">
    <input type="checkbox" name="lock" value="{{d.zhcs}}" title="收藏" lay-filter="lockDemo" {{ d.sfsc== 1
           ? 'checked' : '' }}>
</script>
<script type="text/html" id="zszymcTpl">
    {{#  if(d.newMajor === 1){ }}
    <span style="color: #F581B1;" title="{{d.zszymc}}">{{ d.zszymc }}</span>
    {{#  } else { }}
    {{ d.zszymc }}
    {{#  } }}
</script>
<script>
    layui.use(['table', 'form'], function () {
        var $ = layui.jquery
            , table = layui.table
            , form = layui.form;
        layer.load(1);
        form.on('checkbox(lockDemo)', function (obj) {
            var check = obj.elem.checked;
            var v = this.value.split("|");
            if (check) {
                $.post('/hxzy/add', {
                    "candidateId": $("#hid_id").val()
                    , "schoolCode": v[0]
                    , "schoolName": v[1]
                    , "majorCode": v[2]
                    , "majorName": v[3]
                    , "referenceIndex": v[4]
                    , "xzdm": v[5]
                    , "szd": v[6]
                    , "sfbz": v[7]
                    , "zsjhs": v[8]
                    , "bz": v[9]
                    , "status": $("#type").val()
                }, function (data) {
                    if (data.code != '90000') {
                        layer.msg("收藏失败");
                    }
                });
            } else {
                $.post('/hxzy/cancel', {
                    "id": $("#hid_id").val()
                    , "schoolCode": v[0]
                    , "majorCode": v[2]
                    , "referenceIndex": v[4]
                }, function (data) {
                    if (data.code != '90000') {
                        layer.msg("收藏失败");
                    }
                });
            }
        });
        table.render({
            elem: '#wh-list'
            , url: '/candidate/detail'
            , cols: [[
                {field: 'lock', title: '收藏志愿', width: 110, templet: '#checkboxTpl', unresize: true}
                , {field: 'ds', title: '段数', width: 80, sort: true}
                , {
                    field: 'yxdhmc',
                    title: '学校名称',
                    width: 150,
                    templet: '<div><span title="{{d.yxdhmc}}">{{d.yxdhmc}}</span></div>',
                    sort: true
                }
                , {
                    field: 'zszymc',
                    title: '专业名称',
                    width: 140,
                    templet: '#zszymcTpl',
                    sort: true
                }
                , {field: 'ckzsName', title: '参考指数', width: 80, sort: true}
                , {
                    field: 'xkkmyqzw',
                    title: '选考科目',
                    templet: '<div><span title="{{d.xkkmyqzw}}">{{d.xkkmyqzw}}</span></div>',
                    width: 80,
                    sort: true
                }
                , {
                    field: 'ssmcSzd',
                    title: '所在地',
                    templet: '<div><span title="{{d.ssmcSzd}}">{{d.ssmcSzd}}</span></div>',
                    width: 80,
                    sort: true
                }
                , {field: 'sf985Name', title: '985', width: 80, sort: true}
                , {field: 'sf211Name', title: '211', width: 80, sort: true}
                , {field: 'bxlxmc', title: '办学类型', width: 80, sort: true}
                , {field: 'sfsyl', title: '双一流', sort: true}
                , {field: 'sfbz', title: '收费标准', sort: true}
                , {field: 'xzmc', title: '学制', width: 65, sort: true}
                , {field: 'zsjhs', title: '招生计划数', sort: true}
                , {field: 'bz', title: '备注', templet: '<div><span title="{{d.bz}}">{{d.bz}}</span></div>', sort: true}
                , {field: 'dsms', title: '段数描述', width: 140, sort: true}
            ]]
            , where: {
                "id": $("#hid_id").val()
                , "min": $("#min").val()
                , "max": $("#max").val()
                , "provinceCode": $("#provinceCode").val()
                , "zymc": $("#zymc").val()
                , "schoolCode": $("#schoolCode").val()
                , "type": $("#type").val()
            }
            , method: 'post'
            , id: 'idTest'
            , request: {
                pageName: 'currentPage' //页码的参数名称，默认：page
                , limitName: 'pageSize' //每页数据量的参数名，默认：limit
            }
            , response: {
                statusCode: 90000 //成功的状态码，默认：0
                , countName: 'count' //数据总数的字段名称，默认：count
                , dataName: 'data' //数据列表的字段名称，默认：data
            }
            , limit: 50
            , limits: [50, 100, 200, 500, 1000]
            , even: true
            , page: {theme: '#2d5eb7'}
            , done: function (res, curr, count) {
                layer.closeAll('loading');
                if (res.code == 30002) {
                    layer.msg(res.msg);
                    setTimeout(function () {
                        top.location.href = "/login";
                    }, 5000);
                } else if (res.code != 90000) {
                    layer.msg(res.msg);
                }
            }
        });
        var active = {
            del: function () {
                var checkStatus = table.checkStatus('idTest');
                var data = checkStatus.data;
                if (data.length <= 0) {
                    layer.msg("请选择数据");
                    return;
                }
                var ids = "";
                for (var i in data) {
                    ids += data[i].id + ",";
                }
                ids = ids.substring(0, ids.length - 1);
                layer.confirm('确定要删除吗?', {
                    btn: ['确定', '取消']
                }, function (index, layero) {
                    delZy(ids, active);
                }, function (index) {

                });
            }
            , reload: function () {
                var schoolName = $("#schoolName").val();
                var majorName = $("#majorName").val();
                var bxlx = $("#bxlx").val();
                var xzdm = $("#xzdm").val();
                //执行重载
                layer.load(1);
                table.reload('idTest', {
                    page: {
                        curr: 1 //重新从第 1 页开始
                    }
                    , where: {
                        "schoolName": schoolName,
                        "majorName": majorName,
                        "bxlx": bxlx,
                        "xzdm": xzdm
                    }
                });
            }
            , clear: function () {
                layer.confirm('确定要清空志愿吗?', {
                    btn: ['确定', '取消']
                }, function (index, layero) {
                    clearZy(active);
                }, function (index) {

                });
            }
            , export: function () {
                var id = $("#hid_id").val();
                window.location.href = '/hxzy/export?candidateId=' + id;
            }
        };
        $('.layui-btn').on('click', function () {
            var type = $(this).data('type');
            active[type] ? active[type].call(this) : '';
        });
    });

    function delZy(ids, active) {
        $.post("/hxzy/delete", {
            "ids": ids
        }, function (res) {
            if (res.code == 30002) {
                layer.msg(res.msg);
                setTimeout(function () {
                    top.location.href = "/login";
                }, 5000);
            } else if (res.code != 90000) {
                layer.msg(res.msg);
            } else {
                layer.msg("删除成功");
                active.reload();
            }
        });
    }

    function clearZy(active) {
        $.post("/hxzy/clear", {"candidateId": $("#hid_id").val()}, function (res) {
            if (res.code == 30002) {
                layer.msg(res.msg);
                setTimeout(function () {
                    top.location.href = "/login";
                }, 5000);
            } else if (res.code != 90000) {
                layer.msg(res.msg);
            } else {
                layer.msg("清空成功");
                active.reload();
            }
        })
    }
</script>
</body>
</html>